package it.poste.il.compensatore.service.impl;

import it.poste.il.compensatore.dao.OperationDao;
import it.poste.il.compensatore.entities.Operation;
import it.poste.il.compensatore.service.OperationService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Implementation of OperationService.
 */
@Service("operationService")
public class OperationServiceImpl implements OperationService {

	@Autowired(required=true) 
	static OperationDao operationDao;

	
	private static OperationServiceImpl operationServiceImpl;
	
	private OperationServiceImpl()
	{}
	public static OperationServiceImpl getInstance()
	{
		if(operationServiceImpl==null)
			operationServiceImpl=new OperationServiceImpl();
		return operationServiceImpl;
	}
	
	
	/**
	 * Take the operation dao.
	 * @return OperationDao The Operation dao.
	 */
	public OperationDao getOperationDao() {
		return operationDao;
	}

	/**
	 * Set the operation dao.
	 * @param operationDao The operation dao to set.
	 * @return void
	 */
	public void setOperationDao(OperationDao operationDao) {
		this.operationDao = operationDao;
	}

	/**
	 * Method that retrieve the operation by id.
	 * @param id Id to identify the operation.
	 * @return Operation The entity operation.
	 */
	public Operation retrieveByID(Long id) {
		return operationDao.loadById(id);
	}

	/**
	 * Method that retrieve the string ObjHelper by operation.
	 * @param opt The Operation.
	 * @return String The ObjHelper of the entity Operation.
	 */
	public String selectObjHelper(Operation opt) {
		return operationDao.selectObjHelper(opt);
	}

	/**
	 * The list of all operations.
	 * @return List The list of Operation.
	 */
	public List<Operation> retrieveAll() {
		return operationDao.loadAll();
	}

	/**
	 * Method that save the operation.
	 * @param operation Operation to save.
	 * @return Operation The Operation saved.
	 */
	public Operation save(Operation operation) {
		return operationDao.save(operation);
	}

	/**
	 * Update the operation.
	 * @param operation Operation to update.
	 * @return void
	 */
	public void update(Operation operation) {
		operationDao.update(operation);
	}

	/**
	 * Delete the operation.
	 * @param operation Operation to delete.
	 * @return void
	 */
	public void delete(Operation operation) {
		operationDao.delete(operation);
	}

}
